import { Router } from 'express';
import { matchController } from '../controllers/match.controller.js';

const router = Router();

/**
 * @swagger
 * /api/matches:
 *   post:
 *     tags: [Matches]
 *     summary: 创建比赛记录
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/Match'
 *     responses:
 *       201:
 *         description: 创建成功
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/MatchResponse'
 */
router.post('/', matchController.create);

/**
 * @swagger
 * /api/matches:
 *   get:
 *     tags: [Matches]
 *     summary: 获取比赛列表
 *     parameters:
 *       - in: query
 *         name: page
 *         schema:
 *           type: integer
 *           default: 1
 *         description: 页码
 *       - in: query
 *         name: limit
 *         schema:
 *           type: integer
 *           default: 10
 *         description: 每页数量
 *       - in: query
 *         name: status
 *         schema:
 *           type: string
 *           enum: [active, finished, cancelled]
 *         description: 比赛状态
 *       - in: query
 *         name: is_hot
 *         schema:
 *           type: boolean
 *         description: 是否热门
 *     responses:
 *       200:
 *         description: 获取成功
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/MatchListResponse'
 */
router.get('/', matchController.findAll);

/**
 * @swagger
 * /api/matches/{id}:
 *   get:
 *     tags: [Matches]
 *     summary: 获取比赛详情
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *         description: 比赛ID
 *     responses:
 *       200:
 *         description: 获取成功
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/MatchResponse'
 */
router.get('/:id', matchController.findOne);

/**
 * @swagger
 * /api/matches/{id}:
 *   put:
 *     tags: [Matches]
 *     summary: 更新比赛记录
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *         description: 比赛ID
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/Match'
 *     responses:
 *       200:
 *         description: 更新成功
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/MatchResponse'
 */
router.put('/:id', matchController.update);

/**
 * @swagger
 * /api/matches/{id}:
 *   delete:
 *     tags: [Matches]
 *     summary: 删除比赛记录
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *         description: 比赛ID
 *     responses:
 *       200:
 *         description: 删除成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                 message:
 *                   type: string
 */
router.delete('/:id', matchController.delete);

/**
 * @swagger
 * /api/matches/bulk:
 *   post:
 *     tags: [Matches]
 *     summary: 批量创建比赛记录
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: array
 *             items:
 *               $ref: '#/components/schemas/Match'
 *     responses:
 *       201:
 *         description: 创建成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                 data:
 *                   type: array
 *                   items:
 *                     $ref: '#/components/schemas/Match'
 */
router.post('/bulk', matchController.bulkCreate);

export default router; 